
/*信息详情*/
Ext.define('qjtravel.view.NewsDetail', {
    extend: 'Ext.Container',
    xtype: 'newsDetail',

    requires:[
        'Ext.data.Store',
        'Ext.field.Search',
        "Ext.dataview.List"
    ],
    config:{
        layout: 'card',
        items: [
            {
                xtype:'titlebar',
                title:'最新动态',
                id:'titlebar',
                docked:'top',
                items:[
                    {
                        xtype:'button',
                        text:'返回',
                        handler:function(){
                            Ext.Viewport.remove(this.up('newsDetail'),true);
                            //this.up('newsDetail').destroy()
                        }
                    },
                    {
                        xtype:'button',
                        iconCls:'action',
                        align:'right',
                        action:'newsShare',
                        handler:function(){
                            var newsName = Ext.getCmp('newsName').getValue();
                            var imageURL = Ext.getCmp('imageURL').getValue();
                            console.log(newsName);
                            console.log(imageURL)
                            cordova.exec(function(winParam) {
                                },
                                function(error) {
                                },
                                "Share",
                                "share",
                                ["推荐["+newsName+"]，快用手机下载安装‘曲江智慧旅游’客户端吧 http://xayoudao.com/qujianglvyou/",imageURL,'http://xayoudao.com/qujianglvyou/']);
                        }

                    },
                    {
                        xtype: 'textfield',
                        id: 'newsName',
                        hidden: true
                    },
                    {
                        xtype: 'textfield',
                        id: 'imageURL',
                        hidden: true
                    }
                ]
            },
            {
                xtype:'panel',
                id:'newsdetail',
                scrollable:true,
                listeners: {
                    initialize: function () {
                        Ext.Viewport.mask({xtype: 'loadmask' });
                        Ext.Ajax.request({
                            url: Global.api_url + '/cloud/1/article_info_get',
                            params: {caid: window.localStorage.getItem('NewsDetail_caid')},
                            scope: this,
                            success: function (response) {
                                Ext.Viewport.unmask();
                                var result = Ext.decode(response.responseText);
                                data = result.Variables.data;
                                var length=data.photos.length;
                                var image='';
                                var imageURL;
                                //添加图片
                                for(var i= 0;i<length;i++){
                                    imageURL=data.photos[i].url;
                                    console.log(data.photos[i].name)
                                    image+='<img src='+data.photos[i].url+' width="96%" style="margin:0 10px" />'
                                }
                                Ext.getCmp('titlebar').setTitle('景区动态');
                                Ext.getCmp('newsName').setValue(data.name);
                                Ext.getCmp('imageURL').setValue(imageURL);
                                //加载咨询详细内容
                                this.setHtml(
                                    '<div style="margin: 20px 10px 10px 10px">' +
                                        '<div class="detail_title font2 color1 blod">' + data.name + '</div>' +
                                        '<div class="align_center font1 color1" style="height:22px">' + [Ext.Date.format(new Date(parseInt(data.lasttime) * 1000), 'Y-m-d')] + '</div>' +
                                    '</div>'+
                                        image+
                                    '<div style="margin: 10px" class="content">' + data.content + '</div>'
                                )
                            },
                            failure: function () {
                                Ext.Viewport.unmask();
                                cordova.exec(function (message) {
                                }, function (error) {
                                }, "Messages", "showMsg", ['请求失败', '服务器维护中....']);
                                return false;
                            }
                        })
                    }
                }
            }
        ],listeners: {
            back:function() {
                Ext.Viewport.remove(Ext.Viewport.getActiveItem(), true);
            }
        }
    }


});

